﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Agent
{
    public class CookieHelp
    {
        public const string UserCookieKey = "AGENT_KEY";
        public static void WriteCookie(string strName, string strValue, int DayExpires)
        {
            HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies[strName];
            if (cookie == null)
            {
                cookie = new HttpCookie(strName);
            }
            cookie.Value = strValue;
            cookie.Expires = DateTime.Now.AddDays(DayExpires);
            System.Web.HttpContext.Current.Response.AppendCookie(cookie);
        }
        
        public static void DeleteCookie(string name)
        {
            HttpCookie cookie = new HttpCookie(name);
            cookie.Expires = DateTime.Now.AddYears(-1);
            System.Web.HttpContext.Current.Response.AppendCookie(cookie);
        }
    }
}